<html>
<head><meta charset="utf-8"><title>places-tracking-size · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html">places-tracking-size</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136034270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034270">(Oct 18 2018 at 11:08)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> while explaining someone places and value on miri over lunch, I had an epiphany: I think we should change the <code>meta</code> field in <code>MemPlace</code> from <code>Option&lt;Scalar&gt;</code> to <code>Size</code>. A place refers to a piece of memory, and it seems perfectly sensible to say that we must know location and size of that piece. It also completes a nice symmetry because we already have an <code>Align</code> in there.</p>



<a name="136034327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034327">(Oct 18 2018 at 11:08)</a>:</h4>
<p>but the meta field can also be other things, like a vtable pointer</p>



<a name="136034335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034335">(Oct 18 2018 at 11:09)</a>:</h4>
<p>we only ever need it to compute the size of the place, right?</p>



<a name="136034339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034339">(Oct 18 2018 at 11:09)</a>:</h4>
<p>oh</p>



<a name="136034340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034340">(Oct 18 2018 at 11:09)</a>:</h4>
<p>hm</p>



<a name="136034342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034342">(Oct 18 2018 at 11:09)</a>:</h4>
<p>as in, <code>size_and_align_of</code></p>



<a name="136034355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034355">(Oct 18 2018 at 11:09)</a>:</h4>
<p>MemPlace is already "monomorphized", right?</p>



<a name="136034359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034359">(Oct 18 2018 at 11:09)</a>:</h4>
<p>moreover, we might then want to change <code>memory</code> such that all access happens through a <code>MemPlace</code>. That would group some arguments together nicely, and it'd also have prevented some bugs in my stacked borrows implementation where I accessed memory without doing a value-to-place conversion first, which stacked borrows assume always happens (<span class="user-mention" data-user-id="125253">@Nicole Mazzuca</span> will like this)</p>



<a name="136034401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034401">(Oct 18 2018 at 11:10)</a>:</h4>
<p>"monomorphized"?</p>



<a name="136034426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034426">(Oct 18 2018 at 11:10)</a>:</h4>
<p>I remember you wrote some code for what happens during a deref of a fat pointer</p>



<a name="136034442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034442">(Oct 18 2018 at 11:11)</a>:</h4>
<p>so that the <code>MemPlace</code>'s pointer already points to the beginning of a slice's memory</p>



<a name="136034453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034453">(Oct 18 2018 at 11:11)</a>:</h4>
<p>or in case of a trait object, points to the beginning of the object</p>



<a name="136034503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034503">(Oct 18 2018 at 11:12)</a>:</h4>
<p>ah no that was something else</p>



<a name="136034508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034508">(Oct 18 2018 at 11:12)</a>:</h4>
<p>that was for <code>MPlaceTy</code></p>



<a name="136034513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034513">(Oct 18 2018 at 11:12)</a>:</h4>
<p>monomorphizing the <em>type</em></p>



<a name="136034518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034518">(Oct 18 2018 at 11:12)</a>:</h4>
<p>it is also all gone again because it made no sense</p>



<a name="136034532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034532">(Oct 18 2018 at 11:13)</a>:</h4>
<p>computing the monomorphized type is sometimes hard (like, in <code>Rc&lt;Debug&gt;</code> we'd have to adapt the <code>subst</code>), and sometimes that type doesn't even exist (what is the type of a <code>str</code> with length 10?)</p>



<a name="136034541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034541">(Oct 18 2018 at 11:13)</a>:</h4>
<p>right</p>



<a name="136034639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034639">(Oct 18 2018 at 11:15)</a>:</h4>
<p>I have to say this idea right now excites me quite a bit :)</p>



<a name="136034644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034644">(Oct 18 2018 at 11:15)</a>:</h4>
<p>we already pass ptr-size-align to <code>memory</code></p>



<a name="136034652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034652">(Oct 18 2018 at 11:15)</a>:</h4>
<p>now finally we'd close the gap between that are the <code>MemPlace</code> abstraction</p>



<a name="136034718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034718">(Oct 18 2018 at 11:16)</a>:</h4>
<p>I just checked, but the only place where I thought we'd have run into trouble is <a href="https://github.com/rust-lang/rust/blob/2d81989974a134025be733115574bee8084095b4/src/librustc_mir/interpret/place.rs#L932" target="_blank" title="https://github.com/rust-lang/rust/blob/2d81989974a134025be733115574bee8084095b4/src/librustc_mir/interpret/place.rs#L932">https://github.com/rust-lang/rust/blob/2d81989974a134025be733115574bee8084095b4/src/librustc_mir/interpret/place.rs#L932</a> and that seems fine</p>



<a name="136034937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034937">(Oct 18 2018 at 11:21)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span>  hm... no actually that's not fine</p>



<a name="136034941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034941">(Oct 18 2018 at 11:21)</a>:</h4>
<p>I'll have to see where that gets called</p>



<a name="136034985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034985">(Oct 18 2018 at 11:22)</a>:</h4>
<p>with this, a <code>MemPlace</code> has less information than the reference did</p>



<a name="136034988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034988">(Oct 18 2018 at 11:22)</a>:</h4>
<p>which, uh, also kills the ref-place-roundrip. so maybe this doesn't work... :/</p>



<a name="136034995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136034995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136034995">(Oct 18 2018 at 11:23)</a>:</h4>
<p>but with the instance you should be able to reconstruct everything?</p>



<a name="136035008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136035008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136035008">(Oct 18 2018 at 11:23)</a>:</h4>
<p>but I wouldnt have the instance?</p>



<a name="136035049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136035049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136035049">(Oct 18 2018 at 11:24)</a>:</h4>
<p>also reconstructing the length of a <code>Rc&lt;[u8]&gt;</code> seems rather hard</p>



<a name="136035086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136035086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136035086">(Oct 18 2018 at 11:25)</a>:</h4>
<p>so I think adding <code>Size</code> makes sense, and then we could use <code>MemPlace</code> for the memory interface, but we'd have to keep the <code>meta</code> around to be able to turn a place into a reference again...</p>



<a name="136035296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136035296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136035296">(Oct 18 2018 at 11:30)</a>:</h4>
<p>that ends up making a place larger though, not smaller. and memory really doesn't need that metadata</p>



<a name="136035324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136035324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136035324">(Oct 18 2018 at 11:30)</a>:</h4>
<p>hm... so maybe we should first try to get rid of the <code>Local</code> optimization, see if that hurts; that frees the name <code>Place</code> because we dont need places referring to locals any more. then <code>MemPlace</code> could be ptr+size+align, and <code>Place</code> could be <code>MemPlace</code>+meta</p>



<a name="136035394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136035394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136035394">(Oct 18 2018 at 11:32)</a>:</h4>
<p>and then all memory accesses have to happen through a <code>MemPlace</code></p>



<a name="136036440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136036440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136036440">(Oct 18 2018 at 11:51)</a>:</h4>
<p>I'm currently busy with experimenting with making <code>AllocId</code> an <code>enum</code> to get rid of global ids for allocations</p>



<a name="136036454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136036454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136036454">(Oct 18 2018 at 11:51)</a>:</h4>
<p>but I can take nuking <code>Local</code>s next</p>



<a name="136036581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/places-tracking-size/near/136036581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/places-tracking-size.html#136036581">(Oct 18 2018 at 11:53)</a>:</h4>
<p>let's see who gets there first, and let's avoid race conditions?^^</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>